package cn.iocoder.yudao.module.pay.order.vo;

import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.api.pay.order.eums.UnifiedOrderStatusEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;

import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;

/**
 * 付款单据 Base VO，提供给添加、修改、详细的子 VO 使用
 * 如果子 VO 存在差异的字段，请不要添加到这里，影响 Swagger 文档生成
 *
 * @author aquan
 */
@Data
public class PayOrderBaseVO {

    @Schema(description = "支付单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "PAY202412011838591")
    @NotNull(message = "支付单号不能为空")
    private String no;

    @Schema(description = "商户交易单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "SHP2024111116038888")
    @NotNull(message = "商户交易单号不能为空")
    private String tradeNo;

    @Schema(description = "产品标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆")
    @NotNull(message = "产品标题不能为空")
    private String subject;

    @Schema(description = "产品描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "我是土豆")
    @NotNull(message = "产品描述不能为空")
    private String body;

    @Schema(description = "异步通知地址。主要用于微服务架构，单体架构已进行内部事件监听", example = "http://127.0.0.1:8080/pay/order/notify/wx_lite")
    private String notifyUrl;

    @Schema(description = "支付金额，单位：分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
    @NotNull(message = "支付金额，单位：分不能为空")
    private Long price;

    @Schema(description = "支付渠道：alipay_app、wx_lite、wallet", requiredMode = Schema.RequiredMode.REQUIRED, example = "wallet")
    @NotEmpty(message = "支付渠道不能为空")
    private String channelCode;

    @Schema(description = "渠道用户编号", example = "2048")
    private String channelUserId;

    @Schema(description = "渠道订单号", example = "1888888888888888")
    private String channelOrderNo;

    @Schema(description = "渠道手续费，单位：百分比", example = "10")
    private Double channelFeeRate;

    @Schema(description = "渠道手续金额，单位：分", example = "100")
    private Integer channelFeePrice;

    @Schema(description = "支付状态：0-待付款、10-已付款、20-已退款、30-已关闭", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    @NotNull(message = "支付状态不能为空")
    @InEnum(UnifiedOrderStatusEnum.class)
    private Integer status;

    @Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1")
    @NotNull(message = "用户 IP不能为空")
    private String userIp;

    @Schema(description = "订单失效时间", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotNull(message = "订单失效时间不能为空")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime expireTime;

    @Schema(description = "订单支付成功时间")
    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
    private LocalDateTime successTime;

    @Schema(description = "退款总金额，单位：分", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
    @NotNull(message = "退款总金额，单位：分不能为空")
    private Long refundPrice;

}
